:root {
    --bg-color: #343541;
    --sidebar-bg: #202123;
    --text-color: #ececf1;
    --input-bg: #40414f;
    --border-color: #4d4d4f;
    --button-hover: #2a2b32;
    --message-user-bg: #343541;
    --highlight-color: #10a37f;
    --highlight-hover: #1a7f64;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Söhne', 'ui-sans-serif', 'system-ui', -apple-system, 'Segoe UI', Roboto, Ubuntu, Cantarell, 'Noto Sans', sans-serif, 'Helvetica Neue', Arial, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    padding: 0.5rem;
    flex-shrink: 0;
    transition: transform 0.3s ease;
    overflow: hidden;
    /* Ensure sidebar doesn't expand beyond viewport */
}

.new-chat-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 0.375rem;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-color);
    cursor: pointer;
    font-size: 0.875rem;
    text-align: left;
    margin-bottom: 1rem;
    transition: background-color 0.2s;
}

.new-chat-btn:hover {
    background-color: var(--button-hover);
}

.history-list {
    flex: 1;
    overflow-y: scroll;
    /* Force scrollbar */
    flex-direction: column;
    gap: 0.5rem;
    min-height: 0;
    padding-right: 5px;
    /* Prevent content overlap with scrollbar */
}

/* Specific Scrollbar for History List */
.history-list::-webkit-scrollbar {
    width: 6px;
}

.history-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
}

.history-list::-webkit-scrollbar-thumb {
    background-color: #888;
    border-radius: 3px;
}

.history-list::-webkit-scrollbar-thumb:hover {
    background-color: #aaa;
}

.history-item {
    padding: 0.75rem;
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-color);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    transition: background-color 0.2s;
}

.history-item:hover {
    background-color: var(--button-hover);
}

.history-item.active {
    background-color: var(--input-bg);
}

/* Main Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background-color: var(--bg-color);
}

.chat-header {
    position: sticky;
    top: 0;
    background-color: var(--bg-color);
    z-index: 10;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0.5rem;
    position: relative;
    /* Added for absolute positioning of children */
}


.model-select {
    background-color: transparent;
    color: var(--text-color);
    border: none;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.375rem;
}

.model-select:hover {
    background-color: var(--button-hover);
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 10rem;
    /* Space for input area */
    display: flex;
    flex-direction: column;
}

.welcome-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-color);
    opacity: 0.8;
    text-align: center;
}

.welcome-screen .subtitle {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    opacity: 0.7;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background-color: transparent;
}

::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background-color: var(--text-color);
}

/* Firefox Scrollbar Support */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

/* Messages */
.message {
    padding: 1.5rem;
    display: flex;
    gap: 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.message.user {
    background-color: var(--message-user-bg);
}

.message.assistant {
    background-color: var(--message-assistant-bg);
}


.message-avatar {
    width: 30px;
    height: 30px;
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    flex-shrink: 0;
}

.user .message-avatar {
    background-color: #5436DA;
}

.assistant .message-avatar {
    background-color: #19c37d;
}

/* Input Area */
.input-area-container {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background-image: linear-gradient(180deg, rgba(53, 55, 64, 0), #353740 58.85%);
    padding: 2rem 1rem 1rem;
}

.input-area {
    max-width: 48rem;
    margin: 0 auto;
    position: relative;
    background-color: var(--input-bg);
    border-radius: 0.75rem;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: flex-end;
    padding: 0.75rem;
}

.input-area textarea {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-color);
    font-family: inherit;
    font-size: 1rem;
    resize: none;
    max-height: 200px;
    padding: 0 0.5rem;
    outline: none;
    overflow-y: hidden;
}

.input-area button {
    background: transparent;
    border: none;
    color: var(--text-color);
    padding: 0.25rem;
    border-radius: 0.25rem;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
    align-items: center;
    justify-content: center;
}

.input-area button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.input-area button:not(:disabled):hover {
    background-color: var(--button-hover);
    color: var(--highlight-color);
}

.footer-text {
    text-align: center;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 0.75rem;
}

/* Code Blocks */
pre {
    background-color: black;
    padding: 1rem;
    border-radius: 0.375rem;
    overflow-x: auto;
    margin: 1rem 0;
}


/* Auth Pages */
.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
}

.auth-container {
    width: 100%;
    max-width: 400px;
    padding: 1rem;
}

.auth-box {
    background-color: var(--sidebar-bg);
    /* Use sidebar dark for box */
    padding: 2rem;
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    text-align: center;
}

.auth-box h2 {
    margin-bottom: 2rem;
    font-size: 1.5rem;
    font-weight: 600;
}

.form-group {
    margin-bottom: 1rem;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-color);
}

.form-group input {
    width: 100%;
    padding: 0.75rem;
    border-radius: 0.375rem;
    border: 1px solid var(--border-color);
    background-color: var(--bg-color);
    color: var(--text-color);
    font-size: 1rem;
    outline: none;
}

.form-group input:focus {
    border-color: var(--highlight-color);
}

.auth-btn {
    width: 100%;
    padding: 0.75rem;
    margin-top: 1rem;
    background-color: var(--highlight-color);
    color: white;
    border: none;
    border-radius: 0.375rem;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

.auth-btn:hover {
    background-color: var(--highlight-hover);
}

.auth-footer {
    margin-top: 1.5rem;
    font-size: 0.875rem;
}

.auth-footer a {
    color: var(--highlight-color);
    text-decoration: none;
}

.error-message {
    color: #ef4444;
    font-size: 0.875rem;
    margin-top: 1rem;
    min-height: 1.25rem;
}


/* Sidebar Collapse & Toggle */
.sidebar.collapsed {
    width: 0;
    padding: 0;
    overflow: hidden;
}

.toggle-sidebar-btn {
    position: absolute;
    top: 1rem;
    left: 1rem;
    z-index: 20;
    background: transparent;
    border: none;
    color: var(--text-color);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-sidebar-btn:hover {
    background-color: var(--button-hover);
}

/* Sidebar Profile */
.sidebar-footer {
    border-top: 1px solid var(--border-color);
    padding-top: 0.5rem;
    margin-top: auto;
}

.profile-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem;
    border: none;
    background: transparent;
    color: var(--text-color);
    cursor: pointer;
    border-radius: 0.375rem;
    text-align: left;
    font-size: 0.875rem;
}

.profile-btn:hover {
    background-color: var(--button-hover);
}

.profile-avatar {
    width: 24px;
    height: 24px;
    background-color: #7c3aed;
    /* Different color for profile */
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: bold;
    color: white;
}

/* Close Sidebar Button inside Sidebar */
.close-sidebar-btn {
    align-self: flex-end;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-sidebar-btn:hover {
    background-color: var(--button-hover);
}


/* File Upload */
.attach-btn {
    padding: 0.25rem;
    margin-right: 0.5rem;
    background: transparent;
    border: none;
    color: var(--text-color);
    cursor: pointer;
    border-radius: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.attach-btn:hover {
    background-color: var(--button-hover);
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    width: 100%;
    gap: 0.5rem;
}

/* File Preview in Input */
.file-preview {
    display: none;
    /* Hidden by default */
    align-items: center;
    gap: 0.5rem;
    background-color: var(--button-hover);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    width: fit-content;
}

.file-preview.active {
    display: flex;
}

.remove-file-btn {
    background: transparent;
    border: none;
    color: #ef4444;
    cursor: pointer;
    font-weight: bold;
    margin-left: 0.5rem;
}

.input-area-column {
    flex: 1;
    display: flex;
    flex-direction: column;
}



.message.user {
    justify-content: flex-end;
}

.message.assistant {
    justify-content: flex-start;
}

.message-content {
    max-width: 70%;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    line-height: 1.6;
    word-break: break-word;
}

/* User bubble */
.message.user .message-content {
    background-color: #5436DA;
    color: #fff;
    border-bottom-right-radius: 0.25rem;
}

/* Assistant bubble */
.message.assistant .message-content {
    background-color: #444654;
    color: #ececf1;
    border-bottom-left-radius: 0.25rem;
}

/* Attach Menu (GPT style) */
.attach-wrapper {
    position: relative;
}

.attach-menu {
    position: absolute;
    bottom: 42px;
    left: 0;
    background-color: #202123;
    border: 1px solid #4d4d4f;
    border-radius: 10px;
    display: none;
    flex-direction: column;
    min-width: 190px;
    overflow: hidden;
    z-index: 50;
}

.attach-menu button {
    background: transparent;
    border: none;
    color: #ececf1;
    padding: 12px 14px;
    cursor: pointer;
    text-align: left;
    font-size: 14px;
}

.attach-menu button:hover {
    background-color: #2a2b32;
}

/* Mode / file preview pill */
.file-preview {
    display: none;
    align-items: center;
    gap: 6px;
    background-color: #2a2b32;
    padding: 6px 10px;
    border-radius: 6px;
    margin-bottom: 6px;
    font-size: 13px;
}

.file-preview.active {
    display: flex;
}

.message-content h1,
.message-content h2,
.message-content h3 {
    margin: 0.8em 0 0.4em;
}

.message-content p {
    margin: 0.4em 0;
}

.message-content ul,
.message-content ol {
    margin-left: 1.2em;
}

.message-content pre {
    margin-top: 0.8em;
    padding: 1rem;
    background: #000;
    border-radius: 6px;
}

/* Links in message content - bright and visible */
.message-content a {
    color: #00d9ff;
    text-decoration: underline;
    font-weight: 500;
}

.message-content a:hover {
    color: #5ce1ff;
    text-decoration: none;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background-color: #ccc;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typing {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* ===================================================================
   CRAWL-AI SPECIFIC STYLES
   =================================================================== */

/* Crawl Landing Page */
.crawl-landing {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.crawl-container {
    max-width: 600px;
    width: 100%;
    text-align: center;
}

.crawl-container h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.crawl-container .subtitle {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 2rem;
}

.crawl-input-group {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.crawl-input-group input {
    flex: 1;
    padding: 0.875rem 1rem;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    color: var(--text-color);
    font-size: 1rem;
    outline: none;
}

.crawl-input-group input:focus {
    border-color: var(--highlight-color);
}

.crawl-input-group button {
    padding: 0.875rem 2rem;
    background-color: var(--highlight-color);
    color: white;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.crawl-input-group button:hover:not(:disabled) {
    background-color: var(--highlight-hover);
}

.crawl-input-group button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.crawl-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    color: rgba(255, 255, 255, 0.7);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--highlight-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Crawl Chat Header with URL Display */
.crawl-header {
    display: none;
    /* Hidden as requested */
    align-items: center;
    justify-content: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

/* Voice Input Button */
#voice-btn {
    transition: all 0.2s ease;
}

#voice-btn.listening {
    color: #ef4444;
    /* Red color to indicate recording */
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.crawl-url-display {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background-color: var(--input-bg);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-color);
    max-width: 600px;
    overflow: hidden;
}

.crawl-url-display svg {
    flex-shrink: 0;
    color: var(--highlight-color);
}

.crawl-url-display span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Simplified Input Wrapper for Crawl Chat (No attach button) */
.crawl-input-wrapper {
    display: flex;
    align-items: flex-end;
    width: 100%;
    gap: 0.5rem;
}

.crawl-input-wrapper textarea {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-color);
    font-family: inherit;
    font-size: 1rem;
    resize: none;
    max-height: 200px;
    padding: 0 0.5rem;
    outline: none;
    overflow-y: hidden;
}

/* Navigation Button */
.nav-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 0.375rem;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-color);
    cursor: pointer;
    font-size: 0.875rem;
    text-align: left;
    margin-bottom: 1rem;
    transition: background-color 0.2s;
}

.nav-btn:hover {
    background-color: var(--button-hover);
}

/* Sidebar Section Title */
.sidebar-section {
    padding: 0.5rem 0.75rem;
    margin-top: 0.5rem;
}

.sidebar-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Fix for crawl chat interface scrolling */
#chat-interface {
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .crawl-container h1 {
        font-size: 2rem;
    }

    .crawl-input-group {
        flex-direction: column;
    }

    .crawl-input-group button {
        width: 100%;
    }

}

.crawl-url-display {
    max-width: 100%;
    font-size: 0.75rem;
}


/* Toggle Switch */
.temp-chat-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: 0;
    font-size: 0.9rem;
    font-weight: 500;
    position: absolute;
    right: 1rem;
}

.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #555;
    -webkit-transition: .4s;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    -webkit-transition: .4s;
    transition: .4s;
}

input:checked+.slider {
    background-color: var(--highlight-color);
}

input:focus+.slider {
    box-shadow: 0 0 1px var(--highlight-color);
}

input:checked+.slider:before {
    -webkit-transform: translateX(20px);
    -ms-transform: translateX(20px);
    transform: translateX(20px);
}

/* Rounded sliders */
.slider.round {
    border-radius: 20px;
}

.slider.round:before {
    border-radius: 50%;
}